package com.web.java0328springboot.controller;

import com.web.java0328springboot.entity.ResponseResult;
import com.web.java0328springboot.util.OssUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author lenovo
 * @Description
 * @Date2025/3/28 下午3:10
 */
@CrossOrigin
@RestController
public class UploadController {
    @RequestMapping("/upload")
public ResponseResult upload(MultipartFile file) throws IOException {
    //OSS上传
    OssUtils.upload(file.getInputStream(),file.getOriginalFilename());
    //获得url
    String url = OssUtils.getURL(file.getOriginalFilename());
    return new ResponseResult(200,"OK",url);
}
}
